home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATATYPE.SWG / 0023_ENCYPTION.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  1KB  |  62 lines

  1. {
  2.    Here are two routines: one - encrypts, other - decrypts any data passed.
  3.    They are very simple so if a real hacker will debug your program, he will
  4.    the way the password is encrypted. However, for eye-protection it's really
  5. }
  6. USES Crt;
  7.  
  8. Procedure EncodeBuf(var Buffer; Count : word); assembler;
  9.    { Encrypts Count bytes of data in a Buffer variable }
  10.    Asm
  11.      PUSH DS
  12.      LDS SI,Buffer
  13.      LES DI,Buffer
  14.      CLD
  15.      MOV CX,Count
  16.      OR  CX,0
  17.      JZ  @@2
  18.    @@1:
  19.      LODSB
  20.      XOR AL,2
  21.      ROR AL,1
  22.      NOT AL
  23.      STOSB
  24.      LOOP @@1
  25.    @@2:
  26.      POP DS
  27.    End; { EncodeBuf }
  28.  
  29. Procedure DecodeBuf(var Buffer; Count : word); assembler;
  30.    { Decrypts Count bytes of data from a Buffer variable }
  31.    Asm
  32.      PUSH DS
  33.      LDS SI,Buffer
  34.      LES DI,Buffer
  35.      CLD
  36.      MOV CX,Count
  37.      OR  CX,0
  38.      JZ  @@2
  39.    @@1:
  40.      LODSB
  41.      NOT AL
  42.      ROL AL,1
  43.      XOR AL,2
  44.      STOSB
  45.      LOOP @@1
  46.    @@2:
  47.      POP DS
  48.    End; { DecodeBuf }
  49.  
  50. var Password : string;
  51.  
  52.  Begin
  53.      Write('Enter your password to be encrypted: ');
  54.      ReadLn(Password);
  55.      EncodeBuf(Password[1], Length(Password));
  56.      WriteLn;
  57.      WriteLn('Encrypted password: ', Password);
  58.      DecodeBuf(Password[1], Length(Password));
  59.      WriteLn('Decrypted password: ', Password)
  60.    End.
  61.  
  62.